<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>save (TunecoreDirect::Song)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/tunecore_direct/song.rb, line 30</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>
      <span class="ruby-identifier">req</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-identifier">params</span> = {  <span class="ruby-value str">&quot;album_id&quot;</span>          =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@album_id</span>,
                  <span class="ruby-value str">&quot;name&quot;</span>              =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@name</span>,
                  <span class="ruby-value str">&quot;artist_name&quot;</span>       =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@artist_name</span>,
                  <span class="ruby-value str">&quot;track_num&quot;</span>         =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@track_num</span>,
                  <span class="ruby-value str">&quot;parental_advisory&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@parental_advisory</span> }
      <span class="ruby-identifier">res</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">create_song</span>( <span class="ruby-identifier">params</span> )
      <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unexpected return type: #{res.type}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;song&quot;</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;created&quot;</span>
        <span class="ruby-ivar">@song_id</span> = <span class="ruby-identifier">res</span>.<span class="ruby-identifier">object</span>.<span class="ruby-identifier">song_id</span>
        <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-ivar">@errors</span> = <span class="ruby-identifier">res</span>.<span class="ruby-identifier">errors</span>
        <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
</body>
</html>